<?php
use think\facade\Config;
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>saas</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="<?php echo Config::get('app.static_domian')?>/layui/css/layui.css" media="all">
    <script>
        /^http(s*):\/\//.test(location.href) || alert('请先部署到 localhost 下再访问');
    </script>
</head>
<body class="layui-layout-body">
<div class="layui-card">
    <div class="layui-card-body" style="display: flex;">
        <!--左搜索-->
        <div class="layui-row" style="width: 50%;margin-right: 10px;border: 1px solid #D7D7D7;padding: 10px;display: flex;flex-direction: column;">
            <form action="/index/dictionary" method="post">
                <div style="display: flex">
                    <input style="width: 80%;" type="text" id="keyword" name="keyword" value="<?php echo $keyword;?>" placeholder="请输入表名或表中文名称"  class="layui-input">
                    <button class="layui-btn layui-btn-danger" style="margin-left: 20px;">搜索</button>
                </div>
            </form>

            <!--左下面的显示列表-->
            <div style="overflow-y: scroll;width: 100%;height: 800px;">
                <!--<table class="layui-hide" id="test"></table>-->
                <table class="layui-table" width="30%" id="left_table">
                    <tr>
                        <td>数据库</td>
                        <td>数据表</td>
                    </tr>
                    <volist name="data" id="vo">
                        <?php foreach ($data as $vo){?>
                        <tr id="list">
                            <td ><?php echo $vo['datebase'];?></td>
                            <td  onclick="table_list(this)" tab_name-data="<?php echo $vo['tab_name'];?>"><?php echo $vo['tab_name'];?>（<?php echo $vo['tab_cname'];?>）</td>
                        </tr>
                        <?php }?>
                    </volist>

                </table>
            </div>
        </div>
        <!--右显示-->
        <div class="layui-row" style="width: 70%;border: 1px solid #D7D7D7;padding: 10px;">
            <h2 style="width: 100%;text-align: center;line-height: 45px;border-bottom:1px solid #D7D7D7 ;">表信息</h2>
            <div style="overflow-y: scroll;width: 100%;height: 800px;">
                <table class="layui-table" id="layui-table_id">

                    <thead>
                    <tr>
                        <th>字段名</th>
                        <th>注释</th>
                    </tr>
                    </thead>

                    <tbody id="ullist">
                    <tr>

                    </tr>
                    </tbody>


                </table>
            </div>
        </div>

    </div>
</div>
<script src="<?php echo Config::get('app.static_domian')?>/js/jquery-1.12.3.min.js"></script>
<script src="<?php echo Config::get('app.static_domian')?>/layui/layui.js"></script>
<script type="text/javascript">

    function table_list(t) {
        var tab_name=$(t).attr("tab_name-data");
        $.post('/index/dictionary2', {
            'tab_name': tab_name
        }, function(data) {

            if(data.success){
//               console
                var data = data.data;
                var len =data.length;
                var str='';
                for(var i=0;i<len;i++){
                    str+='<tr><td style="width: 30%">'+data[i]["name"]+'</td><td>'+data[i]["note"]+'</td></tr>';
                }
                $('#ullist').html(str);
            } else if(data.success==false){
                layer.alert(data.msg);
            }
        })
    }
</script>
</body>

</html>
